﻿/// <reference path="tfcore.js"/>
/// <reference path="jquery.js"/>
/*
* This file has been commented to support Visual Studio Intellisense.
* You should not use this file at runtime inside the browser--it is only
* intended to be used only for design-time IntelliSense.  
*
* Comment version: 1.0a
*/

// #pragma NoCompStart
/*
appcommon-vsdoc.js  2.0a
specific functions for the GSF application content windows
*/
// #pragma NoCompEnd
//NameSpaces defined
_TF = top;
TF = document;
TF.APP = {};
TF.APP.Common={};

    //_TF.Common.debug = function(msg) { edNLog.debug(msg, "debug"); };
   TF.APP.Common.getContentElem = function(elID) {
        ///<summary>Get an element reference from the "content" page</summary>
        ///<param name="edID">ID of the element to retrieve</param>
        ///<returns>element object</returns>
        return frames['ifMainContent']._gE(elID);
    };

   TF.APP.Common.contentReload = function() {
        ///<summary>Reloads the content IFrame page from src</summary>
        ///<returns>None.</returns>
        _gE('ifMainContent').src = _gE('ifMainContent').src;
    };

   TF.APP.Common.contentPostBack = function(elTarget, elArgument) {
        ///<summary>Causes a Postback to occur on the Content IFrame page while passing in the target and argument for the postback</summary>
        ///<param name="elTarget">target control name that you want to pass</param>
        ///<param name="elArgument">argument you want to send to the postback (retirevable via EVENTARGUMENT querystring</param>
        ///<returns>None.</returns>
        frames['ifMainContent'].__doPostBack(elTarget, elArgument);
    };

    TF.APP.Common.contentRedirect = function(newURL) {
        ///<summary>Redirects the content IFrame page to a new URL</summary>
        ///<returns>None.</returns>
        _gE('ifMainContent').src = newURL;
    };

    //passthrough functions
    TF.APP.Common.setFocus = function(elementId, frameName) {
        setFocus(elementId, frameName);
    };

    TF.APP.Common.elemStatus = function(strClientId, blnDisabled) {
        _gE(strClientId).disabled = blnDisabled;
    };

    TF.APP.Common.SetDialogTitle = function() {
        ///<summary>Sets the Main screens Title</summary>
        ///<returns>None.</returns>
        SetDialogTitle();
    }
    TF.APP.Common.cShowError = function(txtMessage, iType, callBackFunc) {
        ///<summary>Client Side ShowError</summary>
        ///<param name="txtMessage">The text of the error message to display</param>
        ///<param name="iType">The type of error message: alertTypes = { Error: 1, Warning: 2, Information: 3 } </param>
        ///<param name="callBackFunc">A optional function to run after the message is closed.</param>
        ///<returns>None.</returns>
        _TF.APP.Main.ShowError(txtMessage, iType, callBackFunc);
    };

    TF.APP.Common.elemReadOnly = function(strClientId, blnDisabled) {
        elemReadOnly(strClientId, blnDisabled);
    };


//    if (_TF.is.ff) {
//        HTMLElement.prototype.click = function() {
//            var evt = document.createEvent('MouseEvents');
//            evt.initMouseEvent('click', true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
//            this.dispatchEvent(evt);
//        };
//    }

    stdOnUnload = function() { };
    stdOnload = function() {
        var replaceTitle;
        if (document.forms[0]) { document.forms[0].disabled = false; }
        var metaTag = document.getElementsByName('MESTitle');
        if (metaTag.length > 0) { replaceTitle = metaTag[0].content; metaTag = null; }
        if (replaceTitle != "false" && _TF.PageTitle) { _TF.PageTitle.innerText=document.title; }
        else if (replaceTitle == "false" && _TF.PageTitle) { SetDialogTitle(); }
        if (typeof _TF["CloseAllErrors"] == 'function') { _TF.CloseAllErrors(); }
        if (typeof _TF["SessionRefresh"] == 'function') { _TF.SessionRefresh(); }
        if (typeof window["LocalOnLoad"] == 'function') { LocalOnLoad(); }
    };

// needed for FireFox F1 Help
function processKey(e) { if (e.keyCode == 115) { _TF._gE('btnHelp').click();  e.preventDefault(); return false;  } }
function getHelp(e) { top.window['btnHelp'].click(); return false; }

_AddEvent(window, 'unload', stdOnUnload);
//_TF.Shortcut.add("esc", closeModalDialog);
//document.documentElement.onhelp = getHelp;
document.onhelp = getHelp;
if (_TF.is.ff) { document.onkeydown = processKey; }

$(document).ready(function() {
    $("div.roundbox").wrap('<div class="rnddialog"><div class="bd"><div class="c"><div class="s"></div></div></div></div>');
    $("div.rnddialog").prepend('<div class="hd"><div class="c"></div></div>').append('<div class="ft"><div class="c"></div></div>');
    _TF.$("#btnHelp").attr("rel", location.pathname.replace(".aspx", "_hlp.htm"));
    //_TF.$("#btnHelp").attr("title", _TF.PageTitle.innerText + " Help");
    stdOnload();
});

